package com.water.wfo.component.api.entity.request;

/**
 * packageName com.water.component.api.entity.request
 *
 * @author junhuili
 * @version JDK 8
 * @date 2023/10/28
 * @description TODO
 */
public class PageRequest extends BasicRequest {
    /**
     * 每页默认大小
     */
    public static final int PAGESIZE_DEFAULT = 5;

    /**
     * 每页最小显示数量
     */
    public static final int PAGESIZE_MIN = 1;

    /**
     * 每页最大显示数量
     */
    public static final int PAGESIZE_MAX = 200;

    /**
     * 每页显示数量
     */
    //@NotNull(message = "每页数据数量不能为空")
    protected Integer pageSize;

    /**
     * 页码
     */

    //@NotNull(message = "页码不能为空")
    protected Integer pageNum;

    /**
     * 当前页码(作废)
     */
    @Deprecated
    protected int size;

    public Integer getPageSize() {
        if(null == pageSize) {
            pageSize = PAGESIZE_DEFAULT;
        }
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        if(null == pageSize) {
            pageSize = PAGESIZE_DEFAULT;
        }
        if (pageSize< PAGESIZE_MIN || pageSize > PAGESIZE_MAX) {
            pageSize = PAGESIZE_DEFAULT;
        }
        this.pageSize = pageSize;
    }

    public Integer getPageNum() {
        if (null == pageNum){
            pageNum = PAGESIZE_MIN;
        }
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        if (null == pageNum){
            pageNum = PAGESIZE_MIN;
        }
        this.pageNum = pageNum;
    }

    public String getOrderBy() {
        return null;
    }


    @Deprecated
    public int getSize() {
        return size;
    }

    @Deprecated
    public void setSize(int size) {
        this.size = size;
    }
}
